package com.servlet.yanglaoyuan.mapper;

import com.servlet.yanglaoyuan.pojo.Elderly;
import com.servlet.yanglaoyuan.pojo.ElderlyDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author lingshang
 */
@Mapper
public interface elderlyMapper {

    // 添加老人信息
    @Insert("insert into elderly( name, sex, age, blood_type, height, weight,emer_name,phone,address,emer_phone,emer_relation) " +
        "values(#{name}, #{sex}, #{age}, #{bloodType}, #{height}, #{weight}, #{emerName},#{phone},#{address},#{emerPhone},#{emerRelation})")
    public int add(Elderly elderly);
    // 修改老人信息
    int update(@Param("id") Integer id,@Param("elderly")Elderly elderly);

    //根据id查询老人信息
    @Select("select * from elderly where id = #{id}")
    public Elderly getById(Integer id);

    //删除老人信息
    @Delete("delete from elderly where id = #{id}")
    public int delete(Integer id);
    //查询总记录数
    @Select("select count(*) from elderly")
    public Long findTotal();
    //分页查询所有老人信息
    @Select("select id, name, sex, age, blood_type, height, weight, emer_name, phone, address, emer_phone, emer_relation from elderly")
    public List<Elderly> findAll();
    //根据手机号查询老人信息
    @Select("select * from elderly where phone = #{phone}")
    Elderly getByPhone(String phone);

    public List<Elderly> searchElderly(Map<String, String> params);
}
